package com.miaosha.ms_04.util;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * @Description //MD5工具类
 * @Author Administrator
 * @DATE 2020/9/16 21:19
 **/
public class MD5Util {

    private static String MD5(String value) {
        return DigestUtils.md5Hex(value);
    }

    private static final String salt = "1a2b3c4d";

    public static String inputPassToFormPass(String str) {
        str = "" + salt.charAt(0) + salt.charAt(2) + str + salt.charAt(5) + salt.charAt(4);
        return MD5(str);
    }

    public static String formPassToDBPass(String str, String salt) {
        str = "" + salt.charAt(0) + salt.charAt(2) + str + salt.charAt(5) + salt.charAt(4);
        return MD5(str);
    }

    public static String inputPassToDbPass(String inputPass, String saltDB) {
        String formPass = inputPassToFormPass(inputPass);
        String dbPass = formPassToDBPass(formPass, saltDB);
        return dbPass;
    }

    public static void main(String[] args) {
        String formPass = inputPassToFormPass("123456");
        System.out.println("formPass:" + formPass);
        String dbPass = formPassToDBPass(formPass, "123abc");
        System.out.println(dbPass);
//        System.out.println(inputPassFrom("d3b1294a61a07da9b49b6e22b2cbd7f9"));
    }
}
